<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopOrderAftersaleLogTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_order_aftersale_log', ['comment' => '订单售后记录', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('order_id', 'integer', ['limit' =>  11, 'default' => 0, 'comment' => '订单'])
            ->addColumn('order_aftersale_id', 'integer', ['limit' =>  11, 'default' => 0, 'comment' => '售后单'])
            ->addColumn('oper_type', 'string', ['limit' => 60, 'null' => true, 'default' => null, 'comment' => '操作人类型'])
            ->addColumn('oper_id', 'integer', ['limit' =>  11, 'default' => 0, 'comment' => '操作人'])
            ->addColumn(Column::tinyInteger('dispatch_status')->setDefault(0)->setComment('发货状态:0=未发货,1=已发货,2=已收货'))
            ->addColumn(Column::tinyInteger('aftersale_status')->setDefault(0)->setComment('售后状态:-1=拒绝,0=未申请,1=申请售后,2=售后完成'))
            ->addColumn(Column::tinyInteger('refund_status')->setDefault(0)->setComment('退款状态:0=未退款,1=已同意,2=已完成'))
            ->addColumn('log_type', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '日志类型'])
            ->addColumn('content', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '操作内容'])
            ->addColumn('images', 'string', ['limit'  =>  2500, 'null' => true, 'default' => null, 'comment' => '图片'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->addIndex('order_id')
            ->addIndex('order_aftersale_id')
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('shop_order_aftersale_log');
        $table->drop();
    }
}
